/**
 * Npm 依赖信息
 */

import {
  IPublicTypeComponentDescription,
  IPublicTypeNpmInfo,
  IPublicTypePackage,
} from '@alilc/lowcode-types';
import { IComponentHelper } from './componentHelper';
import { DocClientType, DocFrameType, LcProject, LcProjectPlugin } from './editor.type';
import { Tag } from '../../tag/entities/tag.type';
import { ITypeEntity } from '../../superType/types';

export class LcProjectModule {
  enable?: boolean;
  /**
   * 模块自定义匹配置信息（用于读写）
   */
  config?: Record<string, any>;
  /**
   * 是否安装
   * @default false
   * @description 安装模式下，会自动将全局动作、数据合并进主项目，否则只是在对象树展示引用的组件
   */
  install?: boolean;
  projectId?: string;
  packageName?: string;
  name?: string;
  version?: string;
  /**
   * 忽略资源
   */
  ignore?: {
    documents?: string[];
    actions?: string[];
  };
  /**
   * 导入资源(与ignore互斥)
   */
  import?: {
    documents?: string[];
    actions?: string[];
  };

  installAt?: number;
  installBy?: number;

  project?: LcProject;
}

export class IPublicTypeUtilItem {
  name: string;
  npm?: IPublicTypeNpmInfo;
  /**
   * 引用模块项目ID
   */
  projectId?: string;
  /**
   * 引用于ActionID
   */
  typeId?: string;
}

export class LcProjectAsset {
  enable?: boolean;
  package?: IPublicTypePackage;
  metaFile?: {
    exportName?: string;
    url?: string;
  };
  advanced?: {
    replacePackage?: string;
    prompt?: string;
    frames?: DocFrameType[];
    clients?: DocClientType[];
  };
  components?: IPublicTypeComponentDescription[];
  utils?: IPublicTypeUtilItem[];

  /* 自动安装 */
  autoInstall?: boolean;

  /**
   * 项目ID（表示引用的项目ID，目前考虑用于提示升级）
   */
  projectId?: string;
}

export class LcProjectStoreInfo {
  name?: string;
  packageName?: string;
  version?: string;
  poster?: string;
  description?: string;
  belong?: string;
  isRelease?: boolean;
  isModule?: boolean;
  categroies?: Tag[];
  plugins?: LcLowcodePlugin[];
  actions?: ITypeEntity[];
  actionCases?: ITypeEntity[];
  // 统计信息
  stat?: {
    pageCount?: number;
    componentCount?: number;
    blockCount?: number;
    actionCount?: number;
    installCount?: number;
    pluginCount?: number;
    assetCount?: number;
  };
}

export interface LcLowcodePlugin {
  title: string;
  fileName?: string;
  preload?: boolean;
  icon: string;
  description: string;
  contentProps?: any;
  skeletonProps?: any;
}
